package org.checkboo.hopefullyengine.scenegraph;

import java.nio.IntBuffer;

import org.checkboo.hopefullyengine.boundingvolumes.BoundingVolume;
import org.checkboo.hopefullyengine.sceneelements.BaseObject;
import org.checkboo.math.Quaternion;
import org.checkboo.math.Vector3f;
import org.lwjgl.BufferUtils;

public class GeometryNode extends Node {

	private BaseObject geometry;
	private BoundingVolume boundingVolume;
	private IntBuffer occlusionQueryPointer;
	private boolean occluded;
	
	public GeometryNode(String name){
		super(name);
		this.occlusionQueryPointer = BufferUtils.createIntBuffer(1);
		this.occlusionQueryPointer.put(-1).rewind();
		this.occluded = false;
	}
	
	public GeometryNode(String name, BaseObject geometry, Quaternion rotation, Vector3f translation, Vector3f scale){
		super(name, rotation, translation, scale);
		this.geometry = geometry;
		this.occlusionQueryPointer = BufferUtils.createIntBuffer(1);
		this.occlusionQueryPointer.put(-1).rewind();
		this.occluded = false;
	}

	public BaseObject getGeometry() {
		return geometry;
	}

	public void setGeometry(BaseObject geometry) {
		this.geometry = geometry;
	}
	
	public BoundingVolume getBoundingVolume() {
		return boundingVolume;
	}

	public void setBoundingVolume(BoundingVolume boundingVolume) {
		this.boundingVolume = boundingVolume;
	}
	
	public BoundingVolume updateBound(){
		this.boundingVolume.updateBound(this.getGeometry(), this.getWorldTransform());
		return this.boundingVolume;
	}

	public IntBuffer getOcclusionQueryPointer() {
		return occlusionQueryPointer;
	}

	public void setOcclusionQueryPointer(IntBuffer occlusionQueryPointer) {
		this.occlusionQueryPointer = occlusionQueryPointer;
	}

	public boolean isOccluded() {
		return occluded;
	}

	public void setOccluded(boolean occluded) {
		this.occluded = occluded;
	}
}
